package com.miao.controller;


import com.miao.pay.MiaoPayType;
import com.miao.util.AliPayDTO;
import com.miao.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@Tag(name = "支付服务")
@RestController
@RequestMapping("pay")
@CrossOrigin
public class PayController {

    @Resource
    private MiaoPayType miaoPayType;

    @PostMapping("ailPay")
    @Operation(summary = "支付方法发起")
    public Result<Object> pay(@RequestBody AliPayDTO dto) throws Exception {
        log.info("dto:{}",dto);
        String pay = miaoPayType.Pay(dto);
        return new Result<>().success(pay);
    }

    @PostMapping("notifyUrl")
    @Operation(summary = "支付回调")
    public Result notify(@RequestBody Object obj){
        log.info("支付回调：{}",obj);
        return new Result();
    }

    @PostMapping("/returnUrl")
    @Operation(summary = "结果返回")
    public Result Return(@RequestBody Object obj){
        log.info("结果回调：{}",obj);
        return new Result();
    }


}
